<template>
  <div class="home_page">
    <!-- 轮播 -->
    <van-swipe :autoplay="3000" style="height:150px;">
      <van-swipe-item v-for="(item, index) in bannerInfo" :key="index">
        <img class="banner_image" :src="item.path+'?x-oss-process=image/resize,m_lfit,h_150,w_375/format,png'">
      </van-swipe-item>
    </van-swipe>
    <!-- 通知 -->
    <!-- 热门彩种 -->
    <div class="home_hot">
      <h3 class="home_hot_title">
        <span class="home_hot_icon"></span>
        <span class="home_hot_title_name">热门彩种</span>
      </h3>
      <div class="home_hot_list" style="heigh:345px;">
        <div class="home_hot_item" v-for="(item ,index) in cpList" :key="index" @click="gotoPage(item.key)">
          <img :src="item.logo_url" alt="icon图片">
          <div class="home_hot_item_name" v-text="item.name"></div>
          <div
            class="home_hot_item_info"
            :class="item.intro_is_red==1?'hot_is_ordinary':'hot_is_red'"
            v-text="item.introduce"
          ></div>
        </div>
      </div>
    </div>
    <!-- home_awards_row -->
    <div class="home_awards_row">
      <img 
        src="http://cposs01.oss-cn-beijing.aliyuncs.com/cp/20180716/20180716091926_46157109823.png?x-oss-process=image/resize,p_50"
        alt="推荐图" />
    </div>
    <XCFooter></XCFooter>
  </div>
</template>

<script>
import XCFooter from "@comp/common/XC-footer.vue";
import { Swipe, SwipeItem } from "vant";

export default {
  name: "home",
  data() {
    return {
      bannerInfo: [], // banner 信息
      cpList: []
    };
  },
  components: {
    XCFooter,
    Swipe,
    SwipeItem
  },
  created() {
    // 获取banner
    this.$api.getBanner({}).then(
      res => {
        if (res.http_code === 200) {
          this.bannerInfo = res.data;
        }
      },
      error => {}
    );

    // 获取彩种类别
    this.$api.getCpList({}).then(
      res => {
        if (res.http_code === 200) {
          this.cpList = res.data;
        }
      },
      error => {}
    );

    // 获取轮播消息
    this.$api
      .getMessage({
        page: 1,
        page_size: 10
      })
      .then(res => {}, error => {});
  },
  methods: {
    gotoPage(key){
      let pathName = "";
      switch(key){
        case 'jclq':pathName = "/basketball";break;
        case 'jczq':pathName = "/football";break;
      }
      this.$router.push({
        path:pathName
      })
    }
  }
};
</script>

<style lang="less" scoped>
.home_page {
  padding-bottom: 50px;
  background: @default-background-color;

  img {
    width: 100%;
  }
  
  .home_hot {
    padding: 15px 15px;
    background-color: @default-background-color;

    .home_hot_title {
      margin: 10px 0;
    }
    .home_hot_icon {
      display: inline-block;
      width: 10px;
      height: 10px;
      margin-right: 5px;
      background-color: #fff;
      border: 1px solid @theme-color;
      border-radius: 50%;
    }
    .home_hot_title_name {
      font-size: 20px;
      font-weight: 400;
    }
    .home_hot_list {
      border-radius: 8px;
      background-color: #fff;

      .home_hot_item {
        position: relative;
        display: inline-block;
        width: 33.33%;
        text-align: center;
        font-size: 0.2rem;
        padding: 15px 0;
        img {
          width: 40%;
        }
        .home_hot_item_name {
          margin-top: 12px;
          font-size: 0.3rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          color: #333;
          font-size: 500;
          height: 22px;
        }
        .home_hot_item_info {
          width: 70%; 
          margin: 0 auto;
          padding: 0 8px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
           
        }
        .hot_is_red {
            color: #999;
          }
          .hot_is_ordinary {
            background-color: #ff473a;
            border-radius: 0.15rem;
            color: #fff;
          }
      }
    }
  }

  .banner_image {
    width: 100%;
  }
  .home_awards_row {
    margin: 0 15px 15px;
    border-radius: 0.2rem;
    overflow: hidden;
    background-color: #fff;
    img{
      display: block;
    }
  }
  .ccckkk {
    font-size: 30px;
  }
  .displayName {
    display: flex; // 在编译阶段会自动添加 -webkit- -ms- 前缀
  }
}
</style>
